import request from '@/src/basic/utils/request.js'
import { getUserInfo, removeTokenid, reLaunchToLogin, getUserAccount, saveTokenid } from '@/src/basic/utils/user.js'
import consts from '@/src/consts.js'
import { refreshToken } from '../api'

request.config.baseUrl = consts.BASE_URL

request.interceptor.request = config => {
  config.header['sadais-agent'] = consts.SADAIS_AGENT
  config.header['Access-token'] = uni.getStorageSync('USER_INFO').accessToken
  return config
}

// 处理token过期
request.interceptor.response = response => {
  console.log(response.data)
  return response
}

export default request

export const get = request.get
export const post = request.post
export const put = request.put
export const del = request.del
